﻿using System;
using System.Collections;


using mborn.Model;
using mborn.DAL;

namespace mborn.BLL
{
    public class ArticleBLL
    {
        
        /// <summary>
        /// 添加文章
        /// </summary>
        /// <param name="article">需添加的Article实体类</param>
        public void AddArticle(Article article)
        {
            ArticleDAL dal = new ArticleDAL();
            dal.AddArticle(article);
        }


        /// <summary>
        /// 更新文章信息
        /// </summary>
        /// <param name="article">需更新的Article实体类</param>
        /// <param name="ID">需更新的Article的ID</param>
        public void UpdateArticle(Article article, int ID)
        {
            ArticleDAL dal = new ArticleDAL();
            dal.UpdateArticle(article, ID);
        }


        /// <summary>
        /// 删除文章信息
        /// </summary>
        /// <param name="article">需删除的Article的实体类</param>
        public void DeleteArticle(Article article)
        {
            ArticleDAL dal = new ArticleDAL();
            dal.DeleteArticle(article);
        }


        /// <summary>
        /// 通过UserID得到用户的文章信息
        /// </summary>
        /// <param name="userID">用户的ID</param>
        /// <returns></returns>
        public IList GetArticlesByUserID(int userID)
        {
            string strHQL;
            ArticleDAL dal = new ArticleDAL();
            
            strHQL="from mborn.Model.Article as article where article.UserID="+Convert.ToString(userID);

            return dal.GetAllArticle(strHQL);
        }

    }
}
